{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ddee917a",
   "metadata": {},
   "source": [
    "# detect.py实现功能调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b0fc85ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "import detect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "70f93ccf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648640157,7e118705-916e-4d6c-928f-0617a7fc60b4',\n",
       " 'time_used': 94,\n",
       " 'faces': [{'face_token': '701f3fbff16ef86c515ea4ef7d0bfe3e',\n",
       "   'face_rectangle': {'top': 116, 'left': 188, 'width': 183, 'height': 183}}],\n",
       " 'image_id': 'NqMzJ48nvLIIidvXDooZoQ==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2. api账户/通行证\n",
    "API_key = 'Ks5_WYWbPV5hMgN9kmGZquIMqmVKOYax'\n",
    "API_sercret = 'Fn3E71FHFW0B7lzi_7HzbbKLDaXGqbZV'\n",
    "\n",
    "detect.face_detect(API_key,API_sercret,'han.jpeg')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f01559d3",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648638286,8d98c2c3-004c-46fd-9e63-d460eb96d0fb',\n",
       " 'time_used': 73,\n",
       " 'error_message': 'MISSING_ARGUMENTS: image_url, image_file, image_base64'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b733fa26",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'17f29bb02cbec339c865a3d28f0e72c3'"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "face_token_Liu = detect.face_detect(API_key,API_sercret,'han.jpeg')['faces'][0]['face_token']\n",
    "face_token_Liu"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "736d1a18",
   "metadata": {},
   "source": [
    "# compare.py功能的调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0aeba379",
   "metadata": {},
   "outputs": [],
   "source": [
    "import compare"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "f1172736",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648640859,55069db3-ac78-4256-9972-9e3fff4e3e7d',\n",
       " 'time_used': 64,\n",
       " 'error_message': 'MISSING_ARGUMENTS: face_token1, image_base64_1, image_url1, image_file1'}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "API_key = 'Ks5_WYWbPV5hMgN9kmGZquIMqmVKOYax'\n",
    "API_sercret = 'Fn3E71FHFW0B7lzi_7HzbbKLDaXGqbZV'\n",
    "\n",
    "compare.face_compare(API_key,API_sercret,'han.jpeg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "148f06ba",
   "metadata": {},
   "source": [
    "# search.py功能的调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "1dc2720a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import search"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "a713ea9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 73,\n",
       " 'error_message': 'MISSING_ARGUMENTS: faceset_token, outer_id',\n",
       " 'request_id': '1648640874,dffcdecb-21e3-4650-8c0e-af6b3d6ecfcc'}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "API_key = 'Ks5_WYWbPV5hMgN9kmGZquIMqmVKOYax'\n",
    "API_sercret = 'Fn3E71FHFW0B7lzi_7HzbbKLDaXGqbZV'\n",
    "\n",
    "search.face_search(API_key,API_sercret,'han.jpeg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23d1b871",
   "metadata": {},
   "source": [
    "# analyze.py功能的调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "1869bd59",
   "metadata": {},
   "outputs": [],
   "source": [
    "import analyze"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "9052ef03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 53,\n",
       " 'error_message': 'VOID_REQUEST',\n",
       " 'request_id': '1648640891,bc5036f9-da38-4afb-b0fd-d20bc0447bdf'}"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "analyze.face_analyze(API_key,API_sercret,'han.jpeg')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
